package com.example.springbotorderrabbitmqproducer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class DeadRabbitmqConfig {

    //声明 direct交换机
    @Bean
    public DirectExchange deadExchange() {
        return new DirectExchange("dead-direct-exchange", true, false);
    }

    //声明 队列 sms.direct.queue email.direct.queue duanxin.direct.queue
    @Bean
    public Queue deadQueue() {
        return new Queue("dead.direct.queue", true);
    }

    //完成 交换机和队列的绑定
    @Bean
    public Binding deadExchangeBind() {
        return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("dead");
    }

}
